package cars;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-11-28
 * Time: 10:30
 */
public class Factory {
    private CarList carList;
    private BusList busList;
    private TrunkList trunkList;

    public Factory() {
        this.carList = new CarList();
        this.busList = new BusList();
        this.trunkList = new TrunkList();
    }

    public void addVehicle(int choice){
        Scanner scanner = new Scanner(System.in);
        System.out.print("类型：");
        String brand = scanner.nextLine();
        System.out.print("特征：");
        String val = scanner.nextLine();
        System.out.print("车牌号：");
        String vehicleld = scanner.nextLine();
        System.out.println("每日租金：");
        int  perRent = scanner.nextInt();
        if (choice == 1){
            Car car = new Car(vehicleld, brand, val, perRent);
            carList.list.add(car);
        }else if (choice == 2){
            Bus bus = new Bus(vehicleld, brand, val, perRent);
            busList.list.add(bus);
        }else{
            Trunk trunk = new Trunk(vehicleld, brand, val, perRent);
            trunkList.list.add(trunk);
        }
    }
    public void delVehicle(int choice){
        Scanner scanner = new Scanner(System.in);
        System.out.print("类型：");
        String brand = scanner.nextLine();
        System.out.print("特征: ");
        String type = scanner.nextLine();
        int index = carList.del(brand, type);
        if (choice == 1){
            carList.list.remove(index);
        }else if (choice == 2){
            busList.list.remove(index);
        }else{
            trunkList.list.remove(index);
        }
    }
    public void printVehicle(){
        System.out.println("轿车：");
        System.out.println(carList.list);
        System.out.println("客车：");
        System.out.println(busList.list);
        System.out.println("卡车：");
        System.out.println(trunkList.list);
    }
    public void modifyVehicle(int choice){
        Scanner scanner = new Scanner(System.in);
        System.out.print("类型：");
        String brand = scanner.nextLine();
        System.out.print("特征: ");
        String type = scanner.nextLine();
        int index = carList.del(brand, type);
        System.out.println("请输入修改后汽车信息：");
        System.out.print("类型：");
        String newBrand = scanner.nextLine();
        System.out.print("特征：");
        String val = scanner.nextLine();
        System.out.print("车牌号：");
        String vehicleld = scanner.nextLine();
        System.out.print("每日租金：");
        int  perRent = scanner.nextInt();
        if (choice == 1){
            Car car = new Car(vehicleld, brand, type, perRent);
            carList.list.set(index, car);
        }else if (choice == 2){
            Bus bus = new Bus(vehicleld, brand, type, perRent);
            busList.list.set(index, bus);
        }else{
            Trunk trunk = new Trunk(vehicleld, brand, type, perRent);
            trunkList.list.set(index, trunk);
        }
    }
    public CarList getCarList() {
        return carList;
    }

    public void setCarList(CarList carList) {
        this.carList = carList;
    }

    public BusList getBusList() {
        return busList;
    }

    public void setBusList(BusList busList) {
        this.busList = busList;
    }

    public TrunkList getTrunkList() {
        return trunkList;
    }

    public void setTrunkList(TrunkList trunkList) {
        this.trunkList = trunkList;
    }
}
